package utils

import (
	"github.com/gin-gonic/gin"
	"strconv"
)

// GetCurrentUserId 获取当前用户ID
func GetCurrentUserId(ctx *gin.Context) (userId int64, err error) {
	//uid, ok := ctx.Get(CtxUserIDKey)
	//if !ok {
	//	err = ErrorUserNotLogin
	//	return
	//}
	//userId, ok = uid.(int64)
	//if !ok {
	//	err = ErrorUserNotLogin
	//	return
	//}
	//return
	return
}

// 获取分页变量
func GetPageInfo(ctx *gin.Context) (int64,int64) {
	pageStr := ctx.Query("page")
	sizeStr := ctx.Query("size")

	var (
		page int64
		size int64
		err error
	)

	page,err = strconv.ParseInt(pageStr, 10, 64)
	if err != nil { page = 1 }

	size,err = strconv.ParseInt(sizeStr, 10, 64)
	if err != nil { size = 10 }

	return page, size
}
